package com.lxm.entity;

import com.lxm.entity.query.QuerySenData;
import lombok.Data;

import java.util.Date;
import java.util.Objects;

/**
 * @author ：Administrator
 * @date :创建时间 2021/12/28 13:55
 */
@Data
public class SmsSenMsgEntity {
    private String id;
    private String senContent;
    private Date createTime;
    private Date senTime;
    private String userId;
    private String title;
    private String authCode;
    private String sendType;

    public static SmsSenMsgEntity buildSmsSenMsgEntity(UserEntity user , QuerySenData querySenData){
        SmsSenMsgEntity smsSenMsgEntity = new SmsSenMsgEntity();
        smsSenMsgEntity.setSenContent(querySenData.getContent());
        smsSenMsgEntity.setAuthCode(user.getAuthCode());
        smsSenMsgEntity.setUserId(String.valueOf(user.getId()));
        smsSenMsgEntity.setTitle(querySenData.getTitle());
        smsSenMsgEntity.setSendType(Objects.requireNonNullElse(querySenData.getSendLogo(),""));
        smsSenMsgEntity.setCreateTime(new Date());
        smsSenMsgEntity.setSenTime(new Date());
        return smsSenMsgEntity;
    }
}
